




/*
'===============================================================================
'  MP.LayerHelper.MP_OBS.BL.MbRolesManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using MP.LayerHelper.MP_OBS.BLL;
using MP.LayerHelper.MP_OBS.DAL;
using MP.LayerHelper.MP_OBS.DAL.EntityClasses;
using MP.LayerHelper.MP_OBS.DAL.FactoryClasses;
using MP.LayerHelper.MP_OBS.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace MP.LayerHelper.MP_OBS.BLL
{
	public class MbRolesManagerBase : ManagerBase
	{
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		
		public MbRolesManagerBase()
		{
			// Nothing for now.
		}
		
		public override string TableName()
        {
            return "MbRoles";
        }
		
		public MbRolesEntity Insert(MbRolesEntity _MbRolesEntity)
		{
			return Insert(_MbRolesEntity, "");
		}
		
		public MbRolesEntity Insert(MbRolesEntity _MbRolesEntity, string controlId)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(_MbRolesEntity, true);
				MbRolesFields field = new MbRolesFields();
                LogEntity(_MbRolesEntity, field, AcInsert, controlId);
			}
			return _MbRolesEntity;
		}

		
		public MbRolesEntity Insert(Guid RoleId, string ApplicationName, string RoleName, bool IsEnable, int RoleLevel, bool IsSystem)
		{
			MbRolesEntity _MbRolesEntity = new MbRolesEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MbRolesEntity.RoleId = RoleId;
				_MbRolesEntity.ApplicationName = ApplicationName;
				_MbRolesEntity.RoleName = RoleName;
				_MbRolesEntity.IsEnable = IsEnable;
				_MbRolesEntity.RoleLevel = RoleLevel;
				_MbRolesEntity.IsSystem = IsSystem;
				MbRolesFields field = new MbRolesFields();
                LogEntity(_MbRolesEntity, field, AcInsert);
				adapter.SaveEntity(_MbRolesEntity, true);
			}
			return _MbRolesEntity;
		}

		public MbRolesEntity Insert(string ApplicationName, string RoleName, bool IsEnable, int RoleLevel, bool IsSystem)
		{
			MbRolesEntity _MbRolesEntity = new MbRolesEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MbRolesEntity.ApplicationName = ApplicationName;
				_MbRolesEntity.RoleName = RoleName;
				_MbRolesEntity.IsEnable = IsEnable;
				_MbRolesEntity.RoleLevel = RoleLevel;
				_MbRolesEntity.IsSystem = IsSystem;
				adapter.SaveEntity(_MbRolesEntity, true);
				MbRolesFields field = new MbRolesFields();
                LogEntity(_MbRolesEntity, field, AcInsert);
			}
			return _MbRolesEntity;
		}
		
		public bool Update(MbRolesEntity _MbRolesEntity)
        {
            return Update(_MbRolesEntity, "");
        }

		public bool Update(MbRolesEntity _MbRolesEntity, string controlId)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(MbRolesFields.RoleId == _MbRolesEntity.RoleId);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_MbRolesEntity, filter);
				toReturn = true;
				
				MbRolesFields field = new MbRolesFields();
                LogEntity(_MbRolesEntity, field, AcUpdate, controlId);
			}
			return toReturn;
		}
		
		public bool Update(MbRolesEntity _MbRolesEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_MbRolesEntity, filter);
				toReturn = true;
				
				MbRolesFields field = new MbRolesFields();
                LogEntity(_MbRolesEntity, field, AcUpdate);
			}
			return toReturn;
		}

		public bool Update(Guid RoleId, string ApplicationName, string RoleName, bool IsEnable, int RoleLevel, bool IsSystem)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MbRolesEntity _MbRolesEntity = new MbRolesEntity(RoleId);
				if (adapter.FetchEntity(_MbRolesEntity))
				{
				
					_MbRolesEntity.ApplicationName = ApplicationName;
					_MbRolesEntity.RoleName = RoleName;
					_MbRolesEntity.IsEnable = IsEnable;
					_MbRolesEntity.RoleLevel = RoleLevel;
					_MbRolesEntity.IsSystem = IsSystem;
					adapter.SaveEntity(_MbRolesEntity, true);
					toReturn = true;
					
					MbRolesFields field = new MbRolesFields();
					LogEntity(_MbRolesEntity, field, AcUpdate);
				}
			}
			return toReturn;
		}

		public bool Delete(Guid RoleId)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MbRolesEntity _MbRolesEntity = new MbRolesEntity(RoleId);
				if (adapter.FetchEntity(_MbRolesEntity))
				{
					adapter.DeleteEntity(_MbRolesEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("MbRolesEntity", null);
			}
		}
		
		
		public int DeleteByRoleId(Guid RoleId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleId == RoleId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbRolesEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByApplicationName(string ApplicationName)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.ApplicationName == ApplicationName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbRolesEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByRoleName(string RoleName)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleName == RoleName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbRolesEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByIsEnable(bool IsEnable)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbRolesEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByRoleLevel(int RoleLevel)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleLevel == RoleLevel);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbRolesEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByIsSystem(bool IsSystem)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.IsSystem == IsSystem);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbRolesEntity", filter);
			}
			return toReturn;
		}
		

		
		public MbRolesEntity SelectOne(Guid RoleId)
		{
			MbRolesEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MbRolesEntity _MbRolesEntity = new MbRolesEntity(RoleId);
				if (adapter.FetchEntity(_MbRolesEntity))
				{
					toReturn = _MbRolesEntity;
				}
			}
			return toReturn;
		}

		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbRolesCollection = new EntityCollection(new MbRolesEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbRolesCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectAllLST()
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, null, 0, null);
			}
			return _MbRolesCollection;
		}
		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectAllLST_Paged(int PageNumber, int PageSize)
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, null, 0, null, null, PageNumber, PageSize);
			}
			return _MbRolesCollection;
		}


		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectByRoleIdLST(Guid RoleId)
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleId == RoleId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, filter, 0, null);
			}
			return _MbRolesCollection;
		}
		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectByRoleIdLST_Paged(Guid RoleId, int PageNumber, int PageSize)
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleId == RoleId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbRolesCollection;
		}
		
		// Return DataTable
		public DataTable SelectByRoleIdRDT(Guid RoleId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbRolesCollection = new EntityCollection(new MbRolesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleId == RoleId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbRolesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByRoleIdRDT_Paged(Guid RoleId, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbRolesCollection = new EntityCollection(new MbRolesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleId == RoleId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbRolesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectByApplicationNameLST(string ApplicationName)
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.ApplicationName == ApplicationName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, filter, 0, null);
			}
			return _MbRolesCollection;
		}
		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectByApplicationNameLST_Paged(string ApplicationName, int PageNumber, int PageSize)
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.ApplicationName == ApplicationName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbRolesCollection;
		}
		
		// Return DataTable
		public DataTable SelectByApplicationNameRDT(string ApplicationName)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbRolesCollection = new EntityCollection(new MbRolesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.ApplicationName == ApplicationName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbRolesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByApplicationNameRDT_Paged(string ApplicationName, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbRolesCollection = new EntityCollection(new MbRolesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.ApplicationName == ApplicationName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbRolesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectByRoleNameLST(string RoleName)
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleName == RoleName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, filter, 0, null);
			}
			return _MbRolesCollection;
		}
		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectByRoleNameLST_Paged(string RoleName, int PageNumber, int PageSize)
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleName == RoleName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbRolesCollection;
		}
		
		// Return DataTable
		public DataTable SelectByRoleNameRDT(string RoleName)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbRolesCollection = new EntityCollection(new MbRolesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleName == RoleName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbRolesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByRoleNameRDT_Paged(string RoleName, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbRolesCollection = new EntityCollection(new MbRolesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleName == RoleName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbRolesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectByIsEnableLST(bool IsEnable)
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, filter, 0, null);
			}
			return _MbRolesCollection;
		}
		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectByIsEnableLST_Paged(bool IsEnable, int PageNumber, int PageSize)
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbRolesCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIsEnableRDT(bool IsEnable)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbRolesCollection = new EntityCollection(new MbRolesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbRolesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByIsEnableRDT_Paged(bool IsEnable, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbRolesCollection = new EntityCollection(new MbRolesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbRolesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectByRoleLevelLST(int RoleLevel)
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleLevel == RoleLevel);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, filter, 0, null);
			}
			return _MbRolesCollection;
		}
		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectByRoleLevelLST_Paged(int RoleLevel, int PageNumber, int PageSize)
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleLevel == RoleLevel);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbRolesCollection;
		}
		
		// Return DataTable
		public DataTable SelectByRoleLevelRDT(int RoleLevel)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbRolesCollection = new EntityCollection(new MbRolesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleLevel == RoleLevel);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbRolesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByRoleLevelRDT_Paged(int RoleLevel, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbRolesCollection = new EntityCollection(new MbRolesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.RoleLevel == RoleLevel);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbRolesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectByIsSystemLST(bool IsSystem)
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.IsSystem == IsSystem);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, filter, 0, null);
			}
			return _MbRolesCollection;
		}
		
		// Return EntityCollection<MbRolesEntity>
		public EntityCollection<MbRolesEntity> SelectByIsSystemLST_Paged(bool IsSystem, int PageNumber, int PageSize)
		{
			EntityCollection<MbRolesEntity> _MbRolesCollection = new EntityCollection<MbRolesEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.IsSystem == IsSystem);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbRolesCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbRolesCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIsSystemRDT(bool IsSystem)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbRolesCollection = new EntityCollection(new MbRolesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.IsSystem == IsSystem);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbRolesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByIsSystemRDT_Paged(bool IsSystem, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbRolesCollection = new EntityCollection(new MbRolesEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbRolesFields.IsSystem == IsSystem);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbRolesCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		

	}
}
